-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: add flush_cstdio function #3949
Conversation
This might be incorrect, since the stream may be (should be?) non-blocking at the time: http://pubs.opengroup.org/onlinepubs/009696799/functions/fflush.html It's possible you could write this directly in julia: |
I intentionally don't put it into non-blocking mode since child processes may not know how to deal with that. I think it is reasonable to assume that the stream is blocking since anything else is bad form. |
Good to hear that we open stdout/stderr in the usual blocking mode. Okay to merge, then? (It could throw an exception on an error, but I have a hard time imagining a circumstance when anything useful could be done with such an exception from |
@@ -648,6 +648,12 @@ DLLEXPORT int jl_strtof(char *str, float *out) | |||
|
|||
// showing -------------------------------------------------------------------- | |||
|
|||
void jl_flush_cstdio() | |||
{ | |||
fflush(stdout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
OK. I thought libuv was doing it, but a review of the code reveals that it only does for internal (not spawn-safe) pipes and all sockets. Normal pipes and TTY's are fine (as are normal files). (edit) LGTM. OK to merge. |
@loladiro on a related note, can you put together a |
@vtjnash I'll see what I can do. |
Fixed indentation. |
RFC: add flush_cstdio function
This adds
flush_cstdio()
function, which callsfflush(stdout)
andfflush(stderr)
in C. This is needed in order to flush any output from external C code.(For example, I need this in IJulia in order to make sure external
printf
output is captured after evaluating an input cell.)